#include <stdio.h>
#include <stdlib.h>
#include "sxml_node.h"

int main(int argc, const char* argv[])
{
    struct _sxmlNode* p = NULL;

    if (argc != 2) {
        printf("Need input file\n");
        return -1;
    }

    //Parse
    p = sxmlGetRootElement(argv[1]);

    //Debug walk
    sxmlWalkNode(p);

    //Check
    if ((p->children != NULL) && 
            (p->children->next != NULL) &&
            (p->children->next->children != NULL) &&
            (sxmlHasProp(p->children->next->children, "type"))) {
        printf("Node %s, type=%s, data=%s\n",
                p->children->next->children->name,
                sxmlGetProp(p->children->next->children, "type"),
                sxmlNodeGetContent(p->children->next->children));
    }

    //Clean
    sxmlFreeNode(p);
    p = NULL;

#ifdef SXML_MEM_LEAK_CHECK
    extern void sxml_memory_check();
    sxml_memory_check();
#endif

    return 0;
}

